<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
    <head>
        <base th:href="@{/}">
        <meta charset="UTF-8">
        <title>主页</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" />
        <script src="js/jquery.min.js"></script>
        <script type="text/javascript" th:inline="javascript">
            function deleteComment(id){
                $.ajax({
                    //请求路径，要注意的是url和th:inline="javascript"
                    url : [[@{/comments/delete}]],
                    //请求类型
                    type : "post",
                    //data表示发送的数据
                    data : {
                        id : id
                    },
                    //成功响应的结果
                    success : function(obj){//obj响应数据
                        if(obj == "ok"){
                            history.go(0);
                        }
                    },
                    error : function() {
                        alert("处理异常！");
                    }
                });
            }
        </script>
    </head>
    <body>
        <!-- 加载header.html -->
        <div th:include="admin/header"></div>
        <br><br><br>
        <div class="container">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">评论列表</h3>
                </div>
                <div class="panel-body">
                    <div class="table table-responsive">
                        <table class="table table-bordered table-hover">
                            <tbody class="text-center">
                            <tr>
                                <th>用户</th>
                                <th>评论</th>
                                <th>操作</th>
                            </tr>
                            <tr th:each="comment:${comments}">
                                <td th:text="${comment.bemail}"></td>
                                <td th:text="${comment.content}"></td>
                                <td>
                                    <a th:href="'javascript:deleteComment('+ ${comment.id} +')'" >删除</a>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="3" align="right">
                                    <ul class="pagination">
                                        <li><a>第<span th:text="${currentPage}" ></span>页</a></li>
                                        <li><a>共<span th:if="${totalPage} > 0" th:text="${totalPage}" ></span><span th:if="${totalPage} < 1">1</span>页</a></li>
                                        <li>
                                                <span th:if="${currentPage} != 1" >
                                                    <a th:href="@{selectUser?currentPage=${currentPage - 1}}">上一页</a>
                                                </span>
                                            <span th:if="${currentPage} != ${totalPage} and ${totalPage} > 0" >
                                                    <a th:href="@{selectUser?currentPage=${currentPage - 1}}">下一页</a>
                                                </span>
                                        </li>
                                    </ul>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>